<template>
	<view>
		<view class="tixian-box">
		    <view class="tips">提现金额</view>
		    <view class="mui-input-row">
		        <label>￥</label>
		        <input type="number" @input="money" placeholder="请输入提现金额">
		    </view>
		    <view class="">可提现金额：<span class="money">{{ketixianMoney}}</span></view>
		</view>
		<view class="btn-box">
			<button type="default" @click="tixian()" style="width: 45%;background-color: #FFB800;line-height: 70rpx;font-size: 15px;">申请提现</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				ppid:'',			//品牌ID
				ketixianMoney:0.00,	//可提现金额
				tixianMoney:'',		//提现金额
			}
		},
		onLoad(opt) {
			this.ppid = opt.ppid
			this.ketixianMoney = opt.ketixianMoney
		},
		methods: {
			//申请提现
			tixian(){
				if(this.tixianMoney > this.ketixianMoney){
					this.$u.toast("可提现金额不足")
				}else{
					this.$http.get('/pinpaitixian/userTixian',{
						ppid:this.ppid,
						tixian:this.tixianMoney,
						userid:uni.getStorageSync('usersId')
					}).then(res => {
						if(res.data.code==200){
							this.$u.toast("申请成功")
							this.ketixianMoney = this.ketixianMoney - this.tixianMoney
							uni.$emit("userTixian");
							setTimeout(() => {
								uni.navigateBack()
							},500)
						}else{
							this.$u.toast("申请失败")
						}
					})
				}
			},
			money(e){
				this.tixianMoney = e.target.value
			}
		}
	}
</script>

<style>
	.tixian-box{
		margin-top: 10px;
		background-color: white;
		padding: 10px;
		font-size: 17px;
	}
	.mui-input-row label{
		width: 10%;
		padding: 20rpx 0 20rpx 0;
		float: right;
	}
	.mui-input-row label~input{
		width: 96%;
		padding: 20rpx 0 20rpx 0;
	}
	.mui-input-row{
		border-bottom: 1px solid #ccc;
		margin-bottom: 5px;
		display: flex;
	}
	.btn-box{
		margin-top: 10px;
		text-align: center;
	}
</style>
